#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int t;
string s;

int main() {
#ifdef LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif
    ios::sync_with_stdio(false), cin.tie(0);

    cin >> t;
    while (t--) {
        cin >> s;
        bool flag = false;

        ll a = 0, b = 0;
        for (int i=0; i<s.size();i++) {
            if (i&1) a = a*10+(s[i] - '0');
            else b = b*10 + s[i] - '0';
        }
        cout << (a+1)*(b+1)-2 << endl;
    }
}